package com.wejoy.video.middle.station.api.controller.points;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.wejoy.video.middle.station.api.annotation.LoginCheck;
import com.wejoy.video.middle.station.data.domain.system.SysDept;
import com.wejoy.video.middle.station.data.domain.system.SysUser;
import com.wejoy.video.middle.station.data.service.evs.IEvsHttpService;
import com.wejoy.video.middle.station.data.util.LoginUtil;
import com.wejoy.video.middle.station.data.vo.RespJSON;
import com.wejoy.video.middle.station.data.vo.api.DeptPointVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/point")
public class PointAction {

    @Autowired
    private IEvsHttpService evsHttpService;

    /**
     * 获取点位列表
     * @param pageSize
     * @param pageNo
     * @param deptId
     * @param loginSysUser
     * @return
     */
    @ResponseBody
    @LoginCheck
    @GetMapping("/getPointList")
    public RespJSON getDeptTree(Integer pageSize, Integer pageNo,Integer deptId, String pointName, Boolean includeLowerArea,@SessionAttribute(value = LoginUtil.LOGIN_USER_SESSION_KEY) SysUser loginSysUser){
        return RespJSON.success(evsHttpService.getPoints(loginSysUser.getToken(), pageSize, pageNo, deptId,pointName,includeLowerArea));
    }


    /**
     * 根据点位id获取播放链接
     * @param pointId
     * @param loginSysUser
     * @return
     */
    @ResponseBody
    @LoginCheck
    @GetMapping("/{pointId}/signed_url")
    public RespJSON signedUrl(@PathVariable Integer pointId,String protocol, @SessionAttribute(value = LoginUtil.LOGIN_USER_SESSION_KEY) SysUser loginSysUser){
        return RespJSON.success(evsHttpService.pointsSignedUrl(loginSysUser.getToken(), pointId,protocol));
    }

}
